package Day3;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class JavaTestClass {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        JavaClass jc=new JavaClass();
        System.out.println("新班开班");
        jc.name="java83";
        jc.manageTeacher="李老师";
        jc.dirTeacher="老刘";
        jc.startDate="2023-2-20";
        int choice=0;
        while (true){
            System.out.println("1:加新人,2：查看班级情况,3:查找,4:根据区间查找,5:查找指定位置的学生姓名,6:修改学生,9：退出");
            choice=in.nextInt();
            if(choice==1){
                System.out.print("请输入新人的名字：");
                String name=in.next();
                jc.add(name);
            }else if(choice==2){
                jc.selfIntro();
            }else if(choice==3){
                System.out.println("找谁？");
                String name=in.next();
                boolean insresult = jc.search(name);
                System.out.println(insresult?"这个人在这个班":"查无此人！");
            }else if(choice==4){
                System.out.println("找谁？");
                String name=in.next();
                System.out.println("请输入从第几人开始：");
                int s=in.nextInt();
                System.out.println("请输入从第几人结束：");
                int e=in.nextInt();
                boolean insresult = jc.search2(name,s,e);
                System.out.println(insresult?"这个人在这个班":"查无此人！");
            }else if(choice==5){
                System.out.println("请输入查找的位置：");
                int index=in.nextInt();
                while (index<1||index> jc.names.length){
                    System.out.println("请重新输入：");
                    index=in.nextInt();
                }
                String index2 = jc.find(index);
                System.out.println(index2);
            }else if(choice==6){
                System.out.println("请输入旧的名字：");
                String Oname=in.next();
                System.out.println("请输入新的名字：");
                String Nname=in.next();
                boolean s = jc.change(Oname,Nname);
                System.out.println(s?"修改成功":"修改失败");

            }
            else if(choice==9){
                break;
            }
        }
    }
}
